
// 获取所有可购买的门票信息
exports.getTicketsList = async (scenic_id, category, page = 1, limit = 10) => {
  // 模拟数据
  const tickets = [
    { id: 1, scenic_id: 1, ticket_type: '成人票', price: 50, description: '适用于18岁以上成人' },
    { id: 2, scenic_id: 1, ticket_type: '儿童票', price: 30, description: '适用于12岁以下儿童' },
  ];
  return {
    total: tickets.length,
    page,
    list: tickets.slice((page - 1) * limit, page * limit),
  };
};

// 获取单个票务详情
exports.getTicketById = async (id) => {
  // 模拟数据
  const tickets = [
    { id: 1, scenic_id: 1, ticket_type: '成人票', price: 50, description: '适用于18岁以上成人', available: true, stock: 1000 },
    { id: 2, scenic_id: 1, ticket_type: '儿童票', price: 30, description: '适用于12岁以下儿童', available: true, stock: 500 },
  ];
  return tickets.find(ticket => ticket.id === parseInt(id));
};

// 用户购买门票
exports.createOrder = async (orderData) => {
  // 模拟数据
  const order = {
    order_id: Date.now(),
    ...orderData,
  };
  return order;
};

// 查询用户订单
exports.getUserOrders = async (user_id) => {
  // 模拟数据
  const orders = [
    { order_id: 12345, ticket_id: 1, ticket_type: '成人票', quantity: 2, total_price: 100, order_date: '2025-02-01', status: '待支付' },
    { order_id: 12346, ticket_id: 2, ticket_type: '儿童票', quantity: 1, total_price: 30, order_date: '2025-02-01', status: '已支付' },
  ];
  return orders.filter(order => order.user_id === parseInt(user_id));
};

// 支付订单
exports.payOrder = async (order_id, user_id, payment_method) => {
  // 模拟数据
  const order = { order_id, user_id, payment_method, status: '已支付' };
  return order;
};

// 取消订单
exports.cancelOrder = async (order_id, user_id) => {
  // 模拟数据
  return { order_id, user_id, status: '已取消' };
};

// 退款申请
exports.refundOrder = async (order_id, user_id, reason) => {
  // 模拟数据
  return { order_id, user_id, reason, status: '退款申请中' };
};

// 更新票务库存
exports.updateTicketStock = async (id, stock) => {
  // 模拟数据
  return { id, stock, message: '库存更新成功' };
};
